<template>
  <div id="huishangdiv">
    <div v-if="listLoading" style="margin:20px;">正在加载...</div>
    <div v-else>
      <el-button  @click="pinggushow()" style="right:60px;position:fixed;z-index:999" type="success">查看质量评估</el-button>
      <el-form label-width="90px" v-if="mydata">
        <el-card style="margin:20px 0 0 0;clear:both;overflow:hidden">
          <div slot="header" class="clearfix">
            <span><b>合并一稿通报情况</b></span>
          </div>
          <el-form-item label="通报稿：">
            <b>
              <span v-if="files1&&files1.length>0">
                <div v-for="(item,index) in files1" :key="index">
                  <a href="javascript:void(0)" @click="download(item.id)">{{item.fileName}}.{{item.fileType}}</a>
                  <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template>
                  <br>
                </div>
              </span>
              <span v-else>无</span>
            </b>
          </el-form-item>
        </el-card>
        <el-divider id="shenghuohuiline" content-position="left">或</el-divider>
        <el-card style="margin:20px 0 0 0;clear:both;overflow:hidden">
          <div slot="header" class="clearfix">
            <span><b>通报上年度民主生活会整改措施落实情况</b></span>
          </div>
          <el-form-item label="通报稿：">
            <b>
              <span v-if="files2&&files2.length>0">
                <div v-for="(item,index) in files2" :key="index">
                  <a href="javascript:void(0)" @click="download(item.id)">{{item.fileName}}.{{item.fileType}}</a>
                  <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template>
                  <br>
                </div>
              </span>
              <span v-else>无</span>
            </b>
          </el-form-item>
        </el-card>
        <el-card style="margin:20px 0 0 0;clear:both;overflow:hidden">
          <div slot="header" class="clearfix">
            <span><b>通报巡视整改专题民主生活会整改措施落实情况</b></span>
          </div>
          <el-form-item label="通报稿：">
            <b>
              <div v-if="mydata.weixunshi">未接受巡视</div>
              <span v-if="files3&&files3.length>0">
                <div v-for="(item,index) in files3" :key="index">
                  <a href="javascript:void(0)" @click="download(item.id)">{{item.fileName}}.{{item.fileType}}</a>
                  <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template>
                  <br>
                </div>
              </span>
              <span v-else>无</span>
            </b>
          </el-form-item>
        </el-card>
        <!-- <el-card style="margin:20px 0 0 0;clear:both;overflow:hidden">
          <div slot="header" class="clearfix">
            <span><b>通报“灯下黑”问题专项整治整改措施落实情况</b></span>
          </div>
          <el-form-item label="通报稿：">
            <b>
              <span v-if="files4&&files4.length>0">
                <div v-for="(item,index) in files4" :key="index">
                  <a href="javascript:void(0)" @click="download(item.id)">{{item.fileName}}.{{item.fileType}}</a>
                  <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template>
                  <br>
                </div>
              </span>
              <span v-else>无</span>
            </b>
          </el-form-item>
        </el-card> -->
        <el-card style="margin:20px 0 0 0;clear:both;overflow:hidden">
          <div slot="header" class="clearfix">
            <span><b>通报本次民主生活会征求意见情况</b></span>
          </div>
          <el-form-item label="通报稿：">
            <b>
              <span v-if="files5&&files5.length>0">
                <div v-for="(item,index) in files5" :key="index">
                  <a href="javascript:void(0)" @click="download(item.id)">{{item.fileName}}.{{item.fileType}}</a>
                  <template v-if="item.fileType==='pdf'"><i style="cursor: pointer;" class="el-icon-search" @click="showfile(item.id)" /></template>
                  <br>
                </div>
              </span>
              <span v-else>无</span>
            </b>
          </el-form-item>
        </el-card>
      </el-form>
      <div v-else style="padding:20px; font-size:14px;color:#999;text-align:center">暂无数据</div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    timestamp: '',
    leaders: []
  },
  data () {
    return {
      files1: [],
      files2: [],
      files3: [],
      files4: [],
      files5: [],
      listLoading: false,
      mydata: null,
      pipingren: '',
      beipipingren: '',
      filterList: [],
      sumWenti: 0
    }
  },
  watch: {
    timestamp (val) {
      this.loaddata()
    },
    '$store.state.link_hz' (val) {
      this.activeNameHuishang = this.$store.state.link_hz
    }
    // $refs.tree2.getCurrentNode()
  },
  methods: {
    pinggushow () {
      var params1 = {Link1: 'Pingjia'}
      this.$store.commit('tablink1', params1)
    },
    showfile (id) {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.shenghuohuiAPI + 'api/newFileInfo/download?download=false&id=' + id + '&t=' + new Date())
    },
    download (id) {
      window.open(this.$http.defaults.baseURL + this.$http.defaults.shenghuohuiAPI + 'api/newFileInfo/download?download=true&id=' + id + '&t=' + new Date())
    },
    loaddata () {
      this.listLoading = true
      let para = {
        shenghuohuiunitId: this.$route.params.id,
        pageNum: 1,
        pageSize: 2000
      }
      this.$http
        .post(this.$http.defaults.shenghuohuiAPI + `api/newHzTongbaoqingkuang/queryByPage`, para)
        .then(response => {
          this.listLoading = false
          if (response.data.success === true) {
            console.log('获取成功')
            if (response.data.result.records.length > 0) {
              this.mydata = response.data.result.records[0]
              this.files1 = this.mydata.fileList.filter(item => JSON.parse(item.flag).place === 1)
              this.files2 = this.mydata.fileList.filter(item => JSON.parse(item.flag).place === 2)
              this.files3 = this.mydata.fileList.filter(item => JSON.parse(item.flag).place === 3)
              this.files4 = this.mydata.fileList.filter(item => JSON.parse(item.flag).place === 4)
              this.files5 = this.mydata.fileList.filter(item => JSON.parse(item.flag).place === 5)
            } else {
              this.mydata = null
            }
          } else {
            console.log('获取数据失败:' + response.data.message)
            this.$message({
              message: '获取数据失败:' + response.data.message,
              type: 'error'
            })
          }
        })
        .catch(error => {
          console.log(error)
          this.$message({
            message: '网络获取失败:' + error,
            type: 'error'
          })
          this.listLoading = false
        })
    }
  }
}
</script>
<style scoped>
.el-form-item{
  margin:0;
}
</style>
<style>
#huishangdiv .el-table{
  border: 1px solid #95B8E7 !important;
}
#huishangdiv .el-form-item__label{
  font-size:16px;
}
.chuxi{
  color:green;
}
.nochuxi{
  color:red;
}
#huiyiyicheng .el-form-item__content{
  font-size:16px;
}
</style>
